<?php

use think\facade\Route;
use app\common\middleware\AdminAuthMiddleware;
use app\common\middleware\AdminTokenMiddleware;
use app\common\middleware\AllowOriginMiddleware;
use app\common\middleware\LogMiddleware;

Route::group(function () {


    //常见问题分类
    Route::group('common/problem', function () {
        Route::get('category/lst', '/lst')->name('systemCommonProblemCategoryLst')->option([
            '_alias' => '列表',
        ]);
        Route::get('category/create/form', '/createForm')->name('systemCommonProblemCategoryCreateForm')->option([
            '_alias' => '添加表单',
            '_auth' => false,
            '_form' => 'systemCommonProblemCategoryCreate',
        ]);
        Route::post('category/create', '/create')->name('systemCommonProblemCategoryCreate')->option([
            '_alias' => '添加',
        ]);
        Route::get('category/update/:id/form', '/updateForm')->name('systemCommonProblemCategoryUpdateForm')->option([
            '_alias' => '编辑表单',
            '_auth' => false,
            '_form' => 'systemCommonProblemCategoryUpdate',
        ]);
        Route::post('category/update/:id', '/update')->name('systemCommonProblemCategoryUpdate')->option([
            '_alias' => '编辑',
        ]);
        Route::post('category/status/:id', '/switchStatus')->name('systemCommonProblemCategorySwitchStatus')->option([
            '_alias' => '修改状态',
        ]);
        Route::delete('category/delete/:id', '/delete')->name('systemCommonProblemCategoryDelete')->option([
            '_alias' => '删除',
        ]);

        Route::get('category/tree', '/tree')->name('systemCommonProblemCategoryTree')->option([
            '_alias' => '分类树形结构',
        ]);
    })->prefix('admin.system.common.ProblemCategory')->option([
        '_path' => 'common/problem/classify',
        '_auth' => true,
    ]);


    //常见问题
    Route::group('common/problem', function () {
        Route::get('lst', 'Problem/lst')->name('systemCommonProblemLst')->option([
            '_alias' => '列表',
        ]);
        Route::post('create', 'Problem/create')->name('systemCommonProblemCreate')->option([
            '_alias' => '添加',
        ]);
        Route::post('update/:id', 'Problem/update')->name('systemCommonProblemUpdate')->option([
            '_alias' => '编辑',
        ]);
        Route::post('status/:id', 'Problem/switchStatus')->name('systemCommonProblemSwitchStatus')->option([
            '_alias' => '修改状态',
        ]);
        Route::delete('delete/:id', 'Problem/delete')->name('systemCommonProblemDelete')->option([
            '_alias' => '删除',
        ]);
        Route::get('detail/:id', 'Problem/detail')->name('systemCommonProblemDetail')->option([
            '_alias' => '详情',
        ]);
    })->prefix('admin.system.common.')->option([
        '_path' => 'common/problem/list',
        '_auth' => true,
    ]);
})->middleware(AllowOriginMiddleware::class)
    ->middleware(AdminTokenMiddleware::class, true)
    ->middleware(AdminAuthMiddleware::class)
    ->middleware(LogMiddleware::class);
